Skip to content

chore(lint): add eslint-plugin-node-security so timing-unsafe compares are caught before review - #8586

Open
ofri-peretz wants to merge 1 commit into
ether:developfrom
ofri-peretz:chore/lint-node-security
Open

ofri-peretz wants to merge 1 commit into
ether:developfrom
ofri-peretz:chore/lint-node-security

Conversation

@ofri-peretz

Copy link
Copy Markdown
Contributor

In #8572 we fixed the basic-auth password compare in webaccess.ts so it no longer stops at the first differing character; no-timing-unsafe-compare from eslint-plugin-node-security found it, and I offered a follow-up to add the plugin to your lint setup. This is that follow-up.

It adds eslint-plugin-node-security to src/.eslintrc.cjs (a devDependency plus one override, in the existing eslintrc format), together with eslint-plugin-express-security and eslint-plugin-secure-coding, since the server is Express. The next timing-unsafe compare, unhandled stream error or similar is then caught at the editor or in CI instead of in review.

Only the rules that are clean on the current code are on, including no-timing-unsafe-compare. The recommended rules that misfire here are switched off in the config with a one-line reason each, and there are no inline disables. The only other edit is two ignorePatterns entries for vendored bundles (static/vendor/ and static/js/vendors/jquery.ts, the latter next to the existing jquery.js entry) that the security rules choke on or flag in third-party code.

It also helps agents. This repo has an AGENTS.md and accepts AI-written changes, and when Claude Code, Cursor or Copilot write code here, these rule messages are written for an LLM: each one names the CWE, why it matters and the fix, so the agent corrects its own output in the same edit instead of a reviewer catching it.

Testing: pnpm lint doesn't run on develop at the moment (ESLint 10 no longer reads .eslintrc.*, which I also hit in #8572), so the new block takes effect once lint is restored. To check it anyway I ran ESLint 9 in eslintrc mode with the override from this file and a TypeScript 6 parser over src/ (550 files). I did not run the full existing rule set: typescript-eslint doesn't support TypeScript 7 yet. Problems reported by the three added plugins:

$ eslint --ext .js,.ts,.cjs,.mjs src   # override block from src/.eslintrc.cjs
node-security, express-security, secure-coding: 0 problems

UI changes

  • This PR doesn't add or change anything users see or interact with.
  • This PR changes the UI, and I clicked through it myself in a browser and I'm happy with the UI/UX. If an AI tool wrote any of it, only tick this after you've tried it yourself.

AI disclosure: drafted with AI assistance (Claude); I reviewed and tested the change.

@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Add Node and Express security rules to ESLint

⚙️ Configuration changes ✨ Enhancement 🕐 10-20 Minutes

Grey Divider

AI Description

• Add three security plugins to catch unsafe comparisons and other security patterns during linting.
• Enable their recommended rules, with documented exceptions for findings in the current codebase.
• Exclude vendored assets that produce third-party findings or overwhelm the security rules.
Merge Risk 🟢 Low

Blast radius 🟢 Low 💥 0 capabilities

  • No production behavior changes identified.
Behavioral complexity 🟢 Low 🧩 Assessed behavior

  • No production behavior changes identified.
Potential damage 🟢 Low 🩹 Assessed behavior

  • No production behavior changes identified.
Assessed commit dd036db
Diagram

graph TD
  P["Dev dependencies"] --> S["Security plugins"] --> C["ESLint override"] --> R["Recommended rules"] --> F["Project files"] --> D["Lint diagnostics"]
  C --> V["Vendor exclusions"]
  L["Lint command"] --> C
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Migrate to ESLint flat config alongside the security rules
  • ➕ Makes the new rules enforceable through the current ESLint 10 lint command.
  • ➖ Broadens this PR into a migration of the existing lint configuration and increases regression risk.

Recommendation: The targeted legacy-config addition limits scope and preserves existing rule organization, but it cannot deliver CI enforcement while pnpm lint remains broken under ESLint 10. Restore lint compatibility before treating these rules as a pre-review safeguard; a flat-config migration is the more complete approach if that work belongs in this PR.

Files changed (3) +125 / -0

Other (3) +125 / -0
.eslintrc.cjsConfigure three security rule sets and vendor exclusions +36/-0

Configure three security rule sets and vendor exclusions

• Loads the plugins' recommended rules in a broad override and disables selected rules with explanations for current-code findings. Adds exclusions for vendored jQuery TypeScript and the minified vendor directory.

src/.eslintrc.cjs

package.jsonDeclare security ESLint plugins as development dependencies +3/-0

Declare security ESLint plugins as development dependencies

• Adds express-security, node-security, and secure-coding plugins to the source package's devDependencies.

src/package.json

pnpm-lock.yamlLock security plugins and their shared devkit +86/-0

Lock security plugins and their shared devkit

• Records the three plugin versions and their shared Interlace ESLint devkit in the source importer, package entries, and dependency snapshots.

pnpm-lock.yaml

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Security lint checks never run 🐞 Bug ≡ Correctness
Description
The new security rules are added only to src/.eslintrc.cjs, which the configured ESLint 10
invocation does not read. When developers run pnpm lint, the command cannot apply these rules, so
timing-unsafe comparisons and the other targeted patterns are not checked.
Code

src/.eslintrc.cjs[R33-35]

+        ...recommended('node-security'),
+        ...recommended('express-security'),
+        ...recommended('secure-coding'),
Evidence
The root lint script delegates to the src package, whose script runs eslint . with ESLint 10. The
repository's own lint tooling documents that ESLint ignores .eslintrc.* and lists
eslint.config.* as the config files it reads; the PR places all three recommended rule sets in
.eslintrc.cjs instead.

package.json[14-17]
src/package.json[123-128]
src/package.json[149-152]
bin/plugins/pluginLint.ts[7-17]
src/.eslintrc.cjs[24-35]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The added security rules live in a legacy config that the repository's ESLint invocation does not read, so they provide no lint coverage.
## Fix Focus Areas
- src/.eslintrc.cjs[24-51]
- src/package.json[124-128]
- src/package.json[150-151]
## Recommended Fix
Migrate the security override into a flat ESLint config consumed by the existing `eslint .` command, and verify that `pnpm lint` runs the new rules against source files.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
✅ Cross-repo context — repo relationships
Review mode: Auto: ⚖️ Balanced: Security-focused lint configuration affects broad source-tree validation.

Grey Divider

Tip of the day
💡 Did you know, you can hide the parts of a finding you never read, like the evidence or the agent prompt

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@ofri-peretz

Copy link
Copy Markdown
Contributor Author

Right, and the PR description says so: pnpm lint doesn't run on develop today, because ESLint 10 no longer reads .eslintrc.*. I checked this block with ESLint 9 over 550 files (0 problems). It takes effect once lint runs again. If you'd prefer, I can move it into a flat eslint.config.mjs as part of restoring lint. Say which you want.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant